package sz.szsmk.citizencard.mvp.presenter;

import javax.inject.Inject;

import sz.szsmk.citizencard.model.network.GsdxNetApi;
import sz.szsmk.citizencard.model.network.bean.request.QueryCollectedBusLineReq;
import sz.szsmk.citizencard.model.network.bean.response.QueryBusLineNearbyRes;
import sz.szsmk.citizencard.mvp.contract.ICollecLineContact;
import sz.szsmk.citizencard.retrofitrxjava.ErrorAction;
import sz.szsmk.citizencard.retrofitrxjava.NetworkDateSources;
import sz.szsmk.citizencard.retrofitrxjava.SubscribeResult;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/12/29 15:04
 * description:
 */
public class CollecLinePresenter extends IBasePresenter
        implements ICollecLineContact.ICollecLinePresenter<ICollecLineContact.ICollecLineView> {

    private NetworkDateSources mNetworkDateSource;
    GsdxNetApi gsdxNetApi;

    @Inject
    public CollecLinePresenter(GsdxNetApi gsdxNetApi) {
        this.gsdxNetApi = gsdxNetApi;

        this.mNetworkDateSource = NetworkDateSources.getInstance();
    }


    @Override
    public void queryCollectedBusLine(String string, String userId) {
        QueryCollectedBusLineReq busLineReq = new QueryCollectedBusLineReq();
        busLineReq.setUserID(userId);
        mNetworkDateSource.queryCollectedBusLine(busLineReq, new SubscribeResult<QueryBusLineNearbyRes>() {
            @Override
            protected void onOk(QueryBusLineNearbyRes response) {
                ((ICollecLineContact.ICollecLineView) mView).queryCollectedBusLineSucc(response);
            }

            @Override
            protected void onFailure(QueryBusLineNearbyRes response) {
                super.onFailure(response);
                ((ICollecLineContact.ICollecLineView) mView).queryCollectedBusLineFail(response);
            }
        }, new ErrorAction() {
            @Override
            public void onCall(Throwable throwable) {

            }
        });
    }
}
